home *** CD-ROM | disk | FTP | other *** search
/ com!online 2005 May / com_0505_1.iso / opensource / top10 / amc_install.exe / {app} / Scripts / dvd-maxxx.com (FR).ifs < prev    next >
Encoding:
Text File  |  2005-01-13  |  16.0 KB  |  550 lines

  1. // GETINFO SCRIPTING
  2. // dvd-maxxx.com (FR) - Recherche de films - by Bobo
  3.  
  4. (***************************************************
  5.  *  Movie importation script for:                  *
  6.  *    AdulteDvdX.com                               *
  7.  *                                                 *
  8.  *                                                 *
  9.  *  This program is free software; you can         *
  10.  *  redistribute it and/or modify it under the     *
  11.  *  terms of the GNU General Public License as     *
  12.  *  published by the Free Software Foundation;     *
  13.  *  either version 2 of the License, or (at your   *
  14.  *  option) any later version.                     *
  15.  ***************************************************)
  16.  
  17. program DvdMaxxx;
  18. const
  19.   ConfirmTitre = 1;
  20.     { 1: Demande le titre avant de lancer le script
  21.       2: Ne demande pas le titre avant de lancer le script, 0 : Ne demande aucune comfirmation, 3 : Aucune Confirmation Premier Film si multiples resultats}
  22.   // Pour rΘcupΘrer ou non un champs
  23.   TitreTraduitConst = True;
  24.   TitreOrignalConst = True;
  25.   CategorieConst = True;
  26.   AdresseWebConst = True;
  27.   SynopsisConst = True;
  28.  
  29. var
  30.   MovieName, Adresse, AdressePlus, La_liste, LaAllocine_FR, LaPremiereGrandeImage, Reponse, AdresseSuivant, AdressePrecedent, LePremierFilmAdresse, strTemp, aucunAmazon : string;
  31.   numPage, numPageG, numPageR, grandeTaille, premiereTaille, compteur, premiereExecution, numTemp : Integer;
  32.  
  33. //------------------------------------------------------------------------------
  34. // TROUVE UNE SOUS-CHAINE DE CARACTERE DANS UNE CHAINE
  35. //------------------------------------------------------------------------------
  36.  
  37. function FindLine(Pattern: string; List: TStringList; StartAt: Integer): Integer;
  38. var
  39.   i: Integer;
  40. begin
  41.   result := -1;
  42.   if StartAt < 0 then
  43.     StartAt := 0;
  44.   for i := StartAt to List.Count-1 do
  45.     if Pos(Pattern, List.GetString(i)) <> 0 then
  46.     begin
  47.       result := i;
  48.       Break;
  49.     end;
  50. end;
  51.  
  52. //------------------------------------------------------------------------------
  53. // ANALYSE DE LA PAGE DE RECHERCHES
  54. //------------------------------------------------------------------------------
  55.  
  56. procedure AnalyzePage(Address: string);
  57. var
  58.   Page: TStringList;
  59.   LineNr: Integer;
  60.   Line: string;
  61.   BeginPos, EndPos : Integer;
  62. begin
  63.   Page := TStringList.Create;
  64.   Page.Text := GetPage(Address);
  65.  
  66.   if pos('Aucun produit',Page.Text) <> 0 then
  67.   begin
  68.   if (ConfirmTitre = 1) or (ConfirmTitre = 2) then
  69.   begin
  70.     showmessage('Aucun film trouvΘ pour : '+MovieName);
  71.     exit;
  72.   end else
  73.   begin
  74.     SetField(fieldURL, 'DVD Maxxx : aucun rΘsultat');
  75.     exit;
  76.   end;
  77.   end;
  78.  
  79.     PickTreeClear;
  80.  
  81.     //on se limite α la section o∙ ya les liens du rΘsultat de la recherche
  82.     BeginPos := Pos('vAlign=bottom align="center"><A href=', Page.Text);
  83.     EndPos := length(Page.Text);
  84.     Line := copy(Page.Text,BeginPos,EndPos-BeginPos);
  85.     EndPos := Pos('produits trouvΘs', Line);
  86.     Line := copy(Line,1,EndPos-1);
  87.  
  88.     PickTreeAdd('Films trouvΘs pour ' + MovieName + ' :', '');
  89.     AddMoviesTitles(Line);
  90.     PickTreeAdd(' ', '');
  91.     PickTreeAdd('Verifier si vous avez la derniΦre version', 'version');
  92.  
  93.     if compteur = 1 then
  94.     begin
  95.       compteur := 0;
  96.       AnalyzeMoviePage();
  97.       exit;
  98.     end else if (ConfirmTitre = 1) or (ConfirmTitre = 2) then
  99.     begin
  100.       begin
  101.         if PickTreeExec(Address) then
  102.         begin
  103.           Adresse := Address;
  104.  
  105.      if (Adresse = AdressePlus) then
  106.           begin
  107.             numPageR := numPageR+1;
  108.        AnalyzePage(AdressePlus);
  109.           end else
  110.           if (Adresse = AdressePrecedent) then
  111.           begin
  112.             numPageR := numPageR-1;
  113.        AnalyzePage(AdressePrecedent);
  114.           end else
  115.           if (Adresse = AdresseSuivant) then
  116.           begin
  117.             numPageR := numPageR+1;
  118.        AnalyzePage(AdresseSuivant);
  119.           end else
  120.           begin
  121.             AnalyzeMoviePage();
  122.           end;
  123.         end;
  124.       end;
  125.     end else
  126.     begin
  127.       if (ConfirmTitre = 3) then
  128.       begin
  129.         Adresse := LePremierFilmAdresse;
  130.         AnalyzeMoviePage();
  131.       end else
  132.       begin
  133.         SetField(fieldURL, 'dvd-maxxx : rΘsultats multiples');
  134.         exit;
  135.       end;
  136.     end;
  137.   Page.Free;
  138. end;
  139.  
  140.  
  141. //------------------------------------------------------------------------------
  142. // FONCTION CONVERSION DUREE HEURES EN MINUTES
  143. //------------------------------------------------------------------------------
  144. function h2m(heures : String) : string;
  145. var
  146.   intH, intM : Integer;
  147.  
  148. begin
  149.   intH := StrToInt(copy(heures,1,1),0);
  150.   intM := StrToInt(copy(heures,3,2),0);
  151.   result := IntToStr(intH*60+intM);
  152. end;
  153.  
  154. //------------------------------------------------------------------------------
  155. // ANALYSE DE LA PAGE DU FILM
  156. //------------------------------------------------------------------------------
  157.  
  158. procedure AnalyzeMoviePage();
  159. var
  160.   Line, Value, Value2, AdresseCasting, AdresseSecret, AdresseGalerie, aucun : string;
  161.   LineNr, IntValue: Integer;
  162.   BeginPos, EndPos, FinPos, DureeProdReal: Integer;
  163. begin
  164.  
  165. //charge la page
  166.   Line := GetPage(Adresse);
  167.  
  168. // URL
  169.   if AdresseWebConst = True then
  170.   begin
  171.     if (ConfirmTitre = 3) then
  172.     begin
  173.       SetField(fieldURL, 'DVD Maxxx : α verifier');
  174.     end else
  175.     begin
  176.       SetField(fieldURL, URLEncode(Adresse));
  177.     end;
  178.   end;
  179.  
  180. //titre
  181. //exemple : <span class="txt_title">Les co-locataires - DVD</span>
  182.   if TitreTraduitConst = True then
  183.   begin
  184.   BeginPos := pos('<span class="txt_title">', Line);
  185.   delete(Line,1, BeginPos+3); // +3 : une pette marge
  186.   BeginPos := pos('>', Line)+1;
  187.   EndPos := pos('</span>', Line);
  188.   Value := copy(Line, BeginPos, EndPos - BeginPos);
  189.   if pos(' - DVD', Value) >0 then
  190.   begin
  191.     delete(Value,pos(' - DVD', Value),6);
  192.   end;
  193.   if pos(' - VHS', Value) >0 then
  194.   begin
  195.     delete(Value,pos(' - VHS', Value),6);
  196.   end;
  197.   Value := AnsiUpFirstLetter(Value);
  198.   Value := AnsiMixedCase(Value,' -');
  199.   SetField(fieldTranslatedTitle, Value);
  200.   end;
  201.  
  202. //titre originale (ici = titre)
  203.   if TitreOrignalConst = True then
  204.   begin
  205.     SetField(fieldOriginalTitle, Value);
  206.   end;
  207.  
  208. // Affiche
  209.   BeginPos := pos('<span class="txt_title">', Line);
  210.   Value := copy(Line,BeginPos, length(Line)-BeginPos+1);
  211.   BeginPos := pos('<img src=', Value)+ 10;
  212.   EndPos := pos('" align="left"', Value);
  213.   Value := copy(Value,BeginPos, EndPos-BeginPos);
  214.   if pos('https', Value) > 0 then
  215.   begin
  216.      delete(Value, pos('https', Value)+4,1);
  217.   end;
  218.   GetPicture(Value, False);
  219.  
  220. // RΘsumΘ
  221.   DureeProdReal := 1;
  222.   BeginPos := pos('<p> <strong>ScΘnario:</strong> ', Line)+31;
  223.   if BeginPos > 31 then
  224.   begin
  225.     Value := copy(Line,BeginPos, length(Line)-BeginPos+1);
  226.     EndPos := pos('<!-- fin scenario -->', Value)-1;
  227.     Value := copy(Value,1, EndPos);
  228.     if pos('Points forts', Value) >0 then
  229.     begin
  230.       //points forts dans Commentaires
  231.       Value2 := copy(Value, pos('Points forts', Value)+14, EndPos);
  232.       SetField(fieldComments, cleanText(Trim(Value2)));
  233.       delete(Value, pos('Points forts', Value)-1, EndPos);
  234.     end else if pos('Points Forts', Value) >0 then
  235.     begin
  236.       Value2 := copy(Value, pos('Points Forts', Value)+14, EndPos);
  237.       SetField(fieldComments, cleanText(Trim(Value2)));
  238.       delete(Value, pos('Points Forts', Value)-1, EndPos);
  239.     end;
  240.     SetField(fieldDescription, Trim(cleanText(Value)));
  241.   end else
  242.   begin
  243.     DureeProdReal := 0;
  244.     BeginPos := pos('value="Ajouter au panier"', Line);
  245.     Value := copy(Line, BeginPos, length(Line)-BeginPos+1);
  246.     BeginPos := pos('<br>', Value)+4;
  247.     EndPos := pos('<br></td></tr>', Value)-1;
  248.     Value := copy(Value,BeginPos, EndPos-BeginPos+1);
  249.     SetField(fieldDescription, Trim(cleanText(Value)));
  250.   end;
  251.  
  252. // durΘe
  253.   if DureeProdReal = 1 then
  254.   begin
  255.     BeginPos := pos('<strong>Fiche technique:</strong>', Line)+33;
  256.     Value := copy(Line,BeginPos, 30); //une marge
  257.     BeginPos := pos('durΘe', Value);
  258.     Value := copy(Value, BeginPos, 20); // marge
  259.     BeginPos := pos('h', Value)-1;
  260.     Value := copy(Value,BeginPos, 4);  //style 1h12
  261.     Value := h2m(Value);
  262.     SetField(fieldLength, Value);
  263.  
  264. // producteur
  265. // exemple : <strong>Studio:</strong> Colmax</p>
  266.     BeginPos := pos('Studio:</strong>', Line);
  267.     delete(Line,1, BeginPos+3); // +3 : une pette marge
  268.     BeginPos := pos('>', Line)+2;
  269.     EndPos := pos('</p>', Line);
  270.     Value := copy(Line, BeginPos, EndPos - BeginPos);
  271.     SetField(fieldProducer, cleanText(Trim(Value)));
  272.  
  273. // rΘalisateur
  274. // exemple : RΘalisateur:</strong> Judy Blue
  275.     BeginPos := pos('RΘalisateur:</strong>', Line);
  276.     delete(Line,1, BeginPos+3); // +3 : une pette marge
  277.     BeginPos := pos('>', Line)+2;
  278.     EndPos := pos('<!-- fin realisateur', Line)-2;
  279.     Value := copy(Line, BeginPos, EndPos - BeginPos);
  280.     SetField(fieldDirector, cleanText(Trim(Value)));
  281.   end;
  282.  
  283. // acteurs
  284.   BeginPos := pos('Acteurs / Actrices :', Line);
  285.   delete(Line,1, BeginPos+3); // +3 : une pette marge
  286.   BeginPos := pos('star_name=', Line);
  287.   EndPos := pos('</a></li><br clear="left">', Line);
  288.   Value := copy(Line, BeginPos, EndPos - BeginPos+5); //marge
  289.   AddActors(Value);
  290.  
  291. // Category
  292.   if CategorieConst = True then
  293.   begin
  294.     SetField(fieldCategory, 'XXX');
  295.   end;
  296.  
  297.   DisplayResults;
  298. end;
  299.  
  300. //------------------------------------------------------------------------------
  301. // AJOUTE LES ACTEURS
  302. //------------------------------------------------------------------------------
  303.  
  304. procedure AddActors(var Line: string);
  305. var
  306.   acteurs : String;
  307.   StartPos, EndPos : Integer;
  308. begin
  309.  
  310. acteurs :='';
  311.   repeat
  312.     StartPos := pos('star_name=', Line);
  313.     if StartPos > 0 then
  314.     begin
  315.       delete(Line,1,StartPos+10);
  316.       StartPos := pos('>', Line)+1;
  317.       EndPos := pos('</a>', Line);
  318.       acteurs := acteurs + copy(Line, StartPos, EndPos-StartPos)+', ';
  319.       delete(Line,1,EndPos);
  320.     end;
  321.   until (StartPos < 1);
  322.   delete(acteurs, Length(acteurs)-1, 2);
  323.   SetField(fieldActors, Trim(acteurs));
  324. end;
  325.  
  326. //------------------------------------------------------------------------------
  327. // AJOUTE UN COUPLE FILM / ADRESSE A LA LISTE DE RESULTAT
  328. //------------------------------------------------------------------------------
  329.  
  330. procedure AddMoviesTitles(var Line: string);
  331. var
  332.   MovieTitle, MovieAddress : string;
  333.   StartPos, EndPos : Integer;
  334. begin
  335.  
  336. //compte les rΘsultats
  337.   compteur := 0;
  338.   repeat
  339.     StartPos := pos('vAlign=bottom align="center"><A href="http://www.dvd-maxxx.com', Line)+38;
  340.     if StartPos > 38 then
  341.     begin
  342.       MovieAddress := '';
  343.       MovieTitle := '';
  344.     //exemple lien : <A href="http://www.dvd-maxxx.com/?lang=fr&task=produit&prd_id=2289"
  345.     //exemple titre : <span class=nom_produit>Sinset Boulevard - DVD</span>
  346.  
  347.       EndPos := pos('" title="', Line);
  348.       MovieAddress := copy(Line, StartPos, EndPos-StartPos);
  349.      
  350.       StartPos := pos('<span class=nom_produit>', Line);
  351.       delete(Line,1,StartPos+23);
  352.       EndPos := pos('</span>', Line);
  353.       MovieTitle := copy(Line, 1, EndPos-1);
  354.       PickTreeAdd(MovieTitle, MovieAddress);
  355.       adresse := MovieAddress;
  356.       if (compteur = 0) then
  357.       begin
  358.         LePremierFilmAdresse := adresse;
  359.       end;
  360.       compteur := compteur+1;
  361.     end;
  362.   until (StartPos < 39);
  363. end;
  364.  
  365. //------------------------------------------------------------------------------
  366. // NETTOIE LES TAGS DES TEXTES
  367. //------------------------------------------------------------------------------
  368.  
  369. function cleanText(text : String) : string;
  370. var
  371.   temp : String;
  372. begin
  373.   temp := text;
  374.   temp := StringReplace(temp, #13, '');
  375.   temp := StringReplace(temp, #10, '');
  376.   temp := StringReplace(temp, '<p>', #13#10);
  377.   temp := StringReplace(temp, '</p>', #13#10);
  378.   temp := StringReplace(temp, '<br>', #13#10);
  379.   result := temp;
  380. end;
  381.  
  382. //------------------------------------------------------------------------------
  383. // NETTOIE LE TITRE DU FICHIER POUR AVOIR LE TITRE DE FILM
  384. //------------------------------------------------------------------------------
  385.  
  386. function cleanTitle(title : String) : string;
  387. var
  388.   i,j, fin : Integer;
  389.   temp : String;
  390.  
  391. begin
  392.   title := AnsiUpperCase(title);
  393.  
  394.   if title <> '' then
  395.   begin
  396. // Nettoie les tags fichiers, merci Atmosfear pour les tags
  397.   i:=pos('.DVD',title);
  398.   if i <> 0 then
  399.   begin
  400.     title := copy(title,1,i-1);
  401.   end;
  402.   i:=pos('.DIVX',title);
  403.   if i <> 0 then
  404.   begin
  405.     title := copy(title,1,i-1);
  406.   end;
  407.   i:=pos('.FREN',title);
  408.   if i <> 0 then
  409.   begin
  410.     title := copy(title,1,i-1);
  411.   end;
  412.   i:=pos('.GERM',title);
  413.   if i <> 0 then
  414.   begin
  415.     title := copy(title,1,i-1);
  416.   end;
  417.   i:=pos('.INT',title);
  418.   if i <> 0 then
  419.   begin
  420.     title := copy(title,1,i-1);
  421.   end;
  422.   i:=pos('.LIM',title);
  423.   if i <> 0 then
  424.   begin
  425.     title := copy(title,1,i-1);
  426.   end;
  427.   i:=pos('.PROP',title);
  428.   if i <> 0 then
  429.   begin
  430.     title := copy(title,1,i-1);
  431.   end;
  432.   i:=pos('.REPACK',title);
  433.   if i <> 0 then
  434.   begin
  435.     title := copy(title,1,i-1);
  436.   end;
  437.   i:=pos('.SUBB',title);
  438.   if i <> 0 then
  439.   begin
  440.     title := copy(title,1,i-1);
  441.   end;
  442.   i:=pos('.UNSUB',title);
  443.   if i <> 0 then
  444.   begin
  445.     title := copy(title,1,i-1);
  446.   end;
  447.   i:=pos('.WS',title);
  448.   if i <> 0 then
  449.   begin
  450.     title := copy(title,1,i-1);
  451.   end;
  452.   i:=pos('.XVID',title);
  453.   if i <> 0 then
  454.   begin
  455.     title := copy(title,1,i-1);
  456.   end;
  457.   i:=pos('.AC3',title);
  458.   if i <> 0 then
  459.   begin
  460.     title := copy(title,1,i-1);
  461.   end;
  462.   i:=pos('.UNRAT',title);
  463.   if i <> 0 then
  464.   begin
  465.     title := copy(title,1,i-1);
  466.   end;
  467.  
  468.    title := StringReplace(title, '.', ' ');
  469.    title := StringReplace(title, ',', ' ');
  470.    title := StringReplace(title, ':', '');
  471.    title := StringReplace(title, '-', '');
  472.    title := StringReplace(title, '  ', ' ');
  473.  
  474.    i := 0;
  475. // Nettoie les tags de team
  476.    if (pos('(',title) <> 0) then
  477.    begin
  478.      i := pos('(',title);
  479.      temp := copy(title,0,i-1);
  480.      j := pos(')',title);
  481.      fin := Length(title);
  482.      title := temp + copy(title,j+1,fin);
  483.    end;
  484.  
  485.    if (pos('[',title) <> 0) then
  486.    begin
  487.      i := pos('[',title);
  488.      temp := copy(title,1,i-1);
  489.      j := pos(']',title);
  490.      fin := Length(title);
  491.      title := temp + copy(title,j+1,fin);
  492.    end;
  493.  
  494.    title := AnsiLowerCase(title);
  495.    title := AnsiUpFirstLetter(title);
  496.    title := AnsiMixedCase(title,' -');
  497.   end;
  498.    result := title;
  499. end;
  500.  
  501. //------------------------------------------------------------------------------
  502. // PROGRAMME PRINCIPAL
  503. //------------------------------------------------------------------------------
  504.  
  505. begin
  506.   if CheckVersion(3,4,0) then
  507.   begin
  508.     numPageR := 1;
  509.     MovieName := GetField(fieldTranslatedTitle);
  510.     if MovieName = '' then
  511.       MovieName := GetField(fieldOriginalTitle);
  512.     MovieName := cleanTitle(MovieName);
  513.     if (ConfirmTitre = 1) then
  514.     begin
  515.       if Input('DVD Maxxx', 'Entrez le titre du film :', MovieName) then
  516.       begin
  517.         if Pos('dvdmaxxx.', MovieName) > 0 then
  518.         begin
  519.           adresse := MovieName;
  520.           AnalyzeMoviePage();
  521.         end else
  522.         begin
  523.           AnalyzePage('http://www.dvd-maxxx.com/index.php?task=search&keywords='+UrlEncode(MovieName));
  524.         end;
  525.       end;
  526.     end else
  527.     begin
  528.       if (premiereExecution = 0) then
  529.       begin
  530.           premiereExecution := -1;
  531.      PickTreeClear;
  532.          PickTreeAdd('Vous allez executer le script DVD Maxxx sans confirmation', '');
  533.           PickTreeAdd('Cliquez ici pour continuer', 'Oui');
  534.      PickTreeAdd('Cliquez sur annuler pour ne pas executer le script', '');
  535.      begin
  536.        if PickTreeExec(Reponse)=true then
  537.              if (Reponse = 'Oui') then
  538.              begin
  539.               AnalyzePage('http://www.dvd-maxxx.com/index.php?task=search&keywords='+UrlEncode(MovieName));
  540.        end;
  541.      end;
  542.       end else
  543.       begin
  544.           AnalyzePage('http://www.dvd-maxxx.com/index.php?task=search&keywords='+UrlEncode(MovieName));
  545.       end;
  546.     end;
  547.   end else
  548.     ShowMessage('This script requires a newer version of Ant Movie Catalog (at least the version 3.4.0)');
  549. end.
  550.